<?php
require_once ("../db/connectdatabase.php");
require_once ("../entitys/CardLevel.php");

function getCardLevels() {
	$con = new ConnectDB();
	
	$tbl = "cardlevel";
	$fn = array('idcardlevel', 'cardlevelname', 'datecreate');
	$condetion = array('isuse' => true);
	return $con -> getvalueorderby($tbl, $fn, $condetion, 'datecreate');
}

function getCardLevel($id) {
	$con = new ConnectDB();
	
	$tbl = "cardlevel";
	$fn = array('idcardlevel', 'cardlevelname', 'datecreate');
	$condetion = array('idcardlevel' => $id);
	return $con -> getvalueorderby($tbl, $fn, $condetion, 'datecreate');
}

function insertCardLevel($cardlevel) {
	$con = new ConnectDB();
	
	$tbl = "cardlevel";
	$fn = array('idcardlevel' => ($cardlevel -> getID()), 'cardlevelname' => ($cardlevel -> getName()), 'datecreate' => ($cardlevel -> getDatecreate()));
	return $con -> insert($tbl, $fn);
}

function updateCardLevel($cardlevel) {
	$con = new ConnectDB();
	
	$tbl = "cardlevel";
	$fn = array('cardlevelname' => ($cardlevel -> getName()), 'datecreate' => ($cardlevel -> getDatecreate()));
	$condition = array('idcardlevel' => ($cardlevel -> getID()));
	return $con -> update($tbl, $fn, $condition);
}

function deleteCardLevel($id) {
	$con = new ConnectDB();
	
	$tbl = "cardlevel";
	$fn = array('isuse' => false);
	$condition = array('idcardlevel' => $id);
	return $con -> update($tbl, $fn, $condition);
}
?>